package com.lottery.game.controller.v2.operationalSet;

import com.lottery.game.common.Response;
import com.lottery.game.core.modules.service.app.OperationalSetService;
import com.lottery.game.core.modules.service.game.SysDictService;
import com.lottery.game.model.GameDiscount;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;


@Slf4j
@RestController
@RequestMapping(value = "/operationalSet")
@Api(tags="APP-首页优惠信息")
public class OperationalController {

    @Autowired
    private OperationalSetService operationalSetService;

    @Autowired
    private SysDictService sysDictService;

    @ApiOperation(value = "查询优惠信息", notes = "查询优惠信息", httpMethod="GET")
    @RequestMapping(value = "/queryGameDiscount", method = RequestMethod.GET)
    public Response<List<GameDiscount>> login() {
        List<GameDiscount> list = new ArrayList<>();
        List<Map<String, Object>> resultList = operationalSetService.queryGameDiscount();
        if (null != resultList && !resultList.isEmpty()) {
            // http://103.104.105.25:8090/images/upload/
            for(Map map:resultList){
                GameDiscount gameDiscount = new GameDiscount();
                if(null != map.get("title")){
                    gameDiscount.setTitle(sysDictService.findImageServerAddress() + map.get("title")+"");
                }
                if(null != map.get("content")){
                    gameDiscount.setContent(map.get("content")+"");
                }
                if(null != map.get("status")){
                    gameDiscount.setStatus(map.get("status")+"");
                }
                list.add(gameDiscount);
            }
        }
        return Response.build(list);
    }





}
